library(rstatix)
library(dplyr)
library(ggplot2)
# A small function helping us to round all numbers (0.123456 -> 0.123)
round_df <- function(df, digits = 3) {
nums <- vapply(df, is.numeric, FUN.VALUE = logical(1))
df[,nums] <- round(df[,nums], digits = digits)
(df)
}
# Loading the CSV file
df <- read.csv("data-wpm-onefactorial.csv")
# Show header if everything is OK
head(df)
# Check if data is normal distributed
round_df(df %>% group_by(Conditions) %>% shapiro_test(WPM))
# Nothing is significant, so we can run a three-way repeated-measures ANOVA
anova <- anova_test(data = df, dv = WPM, wid = SubjectID, within = Conditions, effect.size = "pes")
# Auto correction of degree of freedom (if necessary)
get_anova_table(anova, correction = "auto")
# Pairwise Posthoc Comparison to understand where the differences occur
pairwise.t.test(df$WPM, df$Conditions, p.adj = "bonf", paired = TRUE)
# Let's aggregate the data
means <- df %>% group_by(Conditions) %>% summarize(
Mean = mean(WPM),
SD = sd(WPM),
N = n(), .groups = 'drop',) %>% mutate(
SE = SD / sqrt(N),
CI = qt(1 - (0.05 / 2), N - 1) * SE)
# Let's plot the data
plot <- ggplot(means, aes(y=Mean, x=Conditions, fill=Conditions)) +
geom_bar(stat = "identity") +
geom_errorbar(aes(ymin=Mean-CI, ymax=Mean+CI, width=.1)) +
ylab("words per minute (WPM)") +
xlab("")+
ggtitle("Typing performance") +
theme_minimal() +
theme(
legend.margin=margin(t = -5, unit='mm'),
plot.margin=unit(x=c(1,2,1,1),units="mm"),
legend.position = "none",
legend.title = element_blank(),
plot.title = element_text(hjust = 0.5),
panel.background = element_rect(size=0.5, color="transparent", fill="gray98" )
)
options(repr.plot.width = 5, repr.plot.height = 5)
plot
ggsave("Swipe-WPM-BarChart.pdf", plot, width=5, height=5, device=cairo_pdf)
| SubjectID | Sequence | Conditions | WPM | |
|---|---|---|---|---|
| <int> | <int> | <chr> | <dbl> | |
| 1 | 1 | 1 | NoSwipe | 44.559 |
| 2 | 1 | 2 | Swipe | 75.381 |
| 3 | 1 | 3 | VibroSwipe | 88.695 |
| 4 | 2 | 1 | NoSwipe | 42.951 |
| 5 | 2 | 2 | VibroSwipe | 95.790 |
| 6 | 2 | 3 | Swipe | 76.255 |
| Conditions | variable | statistic | p |
|---|---|---|---|
| <chr> | <chr> | <dbl> | <dbl> |
| NoSwipe | WPM | 0.888 | 0.111 |
| Swipe | WPM | 0.979 | 0.979 |
| VibroSwipe | WPM | 0.927 | 0.350 |
| Effect | DFn | DFd | F | p | p<.05 | pes | |
|---|---|---|---|---|---|---|---|
| <chr> | <dbl> | <dbl> | <dbl> | <dbl> | <chr> | <dbl> | |
| 1 | Conditions | 2 | 22 | 24.255 | 2.73e-06 | * | 0.688 |
Pairwise comparisons using paired t tests
data: df$WPM and df$Conditions
NoSwipe Swipe
Swipe 0.00012 -
VibroSwipe 0.00022 1.00000
P value adjustment method: bonferroni
library(rstatix)
library(dplyr)
library(ggplot2)
# A small function helping us to round all numbers (0.123456 -> 0.123)
round_df <- function(df, digits = 3) {
nums <- vapply(df, is.numeric, FUN.VALUE = logical(1))
df[,nums] <- round(df[,nums], digits = digits)
(df)
}
# Loading the CSV file
df <- read.csv("data-tlx-onefactorial.csv")
# Show header if everything is OK
head(df)
# TLX = Mental Demand + Phyiscal Demand + Temporal Demand + Performance + Effort + Frustration
df$TLX <- df$MD + df$PD + df$TD + df$PE + df$EF + df$FR
# Check if data is normal distributed
round_df(df %>% group_by(Conditions) %>% shapiro_test(TLX))
# Nothing is significant, so we can run a three-way repeated-measures ANOVA
anova <- anova_test(data = df, dv = TLX, wid = SubjectID, within = Conditions, effect.size = "pes")
# Auto correction of degree of freedom (if necessary)
get_anova_table(anova, correction = "auto")
# Pairwise Posthoc Comparison to understand where the differences occur
pairwise.t.test(df$TLX, df$Conditions, p.adj = "bonf", paired = TRUE)
# Let's aggregate the data
means <- df %>% group_by(Conditions) %>% summarize(
Mean = mean(TLX),
SD = sd(TLX),
N = n(), .groups = 'drop',) %>% mutate(
SE = SD / sqrt(N),
CI = qt(1 - (0.05 / 2), N - 1) * SE)
# Let's plot the data
plot <- ggplot(means, aes(y=Mean, x=Conditions, fill=Conditions)) +
geom_bar(stat = "identity") +
geom_errorbar(aes(ymin=Mean-CI, ymax=Mean+CI, width=.1)) +
ylab("words per minute (WPM)") +
xlab("")+
ggtitle("Typing performance") +
theme_minimal() +
theme(
legend.margin=margin(t = -5, unit='mm'),
plot.margin=unit(x=c(1,2,1,1),units="mm"),
legend.position = "none",
legend.title = element_blank(),
plot.title = element_text(hjust = 0.5),
panel.background = element_rect(size=0.5, color="transparent", fill="gray98" )
)
options(repr.plot.width = 5, repr.plot.height = 5)
plot
ggsave("Swipe-WPM-BarChart.pdf", plot, width=5, height=5, device=cairo_pdf)
| SubjectID | Sequence | Conditions | MD | PD | TD | PE | EF | FR | |
|---|---|---|---|---|---|---|---|---|---|
| <int> | <int> | <chr> | <int> | <int> | <int> | <int> | <int> | <int> | |
| 1 | 1 | 1 | NoSwipe | 1 | 11 | 12 | 9 | 6 | 0 |
| 2 | 1 | 2 | Swipe | 10 | 11 | 12 | 9 | 10 | 7 |
| 3 | 1 | 3 | VibroSwipe | 12 | 3 | 7 | 0 | 10 | 10 |
| 4 | 2 | 1 | NoSwipe | 1 | 6 | 3 | 2 | 2 | 10 |
| 5 | 2 | 2 | VibroSwipe | 12 | 4 | 13 | 8 | 1 | 9 |
| 6 | 2 | 3 | Swipe | 4 | 8 | 5 | 8 | 5 | 8 |
| Conditions | variable | statistic | p |
|---|---|---|---|
| <chr> | <chr> | <dbl> | <dbl> |
| NoSwipe | TLX | 0.929 | 0.368 |
| Swipe | TLX | 0.910 | 0.216 |
| VibroSwipe | TLX | 0.961 | 0.804 |
| Effect | DFn | DFd | F | p | p<.05 | pes | |
|---|---|---|---|---|---|---|---|
| <chr> | <dbl> | <dbl> | <dbl> | <dbl> | <chr> | <dbl> | |
| 1 | Conditions | 2 | 22 | 4.405 | 0.025 | * | 0.286 |
Pairwise comparisons using paired t tests
data: df$TLX and df$Conditions
NoSwipe Swipe
Swipe 0.110 -
VibroSwipe 0.099 1.000
P value adjustment method: bonferroni